#!/usr/bin/env python3
# coding:utf-8
import rospy
import signal


'''
python 测试节点
sukai
2022-09-19
rosrun contnav test.py
'''

stop = False
# 监听ctrl c
def my_handler(signum, frame):
    global stop
    stop = True
    #关闭节点
    rospy.signal_shutdown("ctrl c!")
    if rospy.is_shutdown():
        print("close ros  test python")
    print("终止")


if __name__ == '__main__':
    # 创建节点
    rospy.init_node("pyhello")

    # 监听ctrl c
    signal.signal(signal.SIGINT, my_handler)    #读取Ctrl+c信号
    print("hello ros python")

    rospy.spin()
